﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows.Controls;
using GalaSoft.MvvmLight.Messaging;

namespace Songhay.Silverlight.BiggestBox.IndexPart
{
    using Songhay.Composition;
    using Songhay.Models;
    using Songhay.Mvvm.Models;
    using Songhay.Silverlight.BiggestBox.IndexPart.Views.UserControls;

    [Export(typeof(ICompositionMessaging))]
    public class CompositionMessaging : ICompositionMessaging
    {
        #region ICompositionMessaging Members

        public void RegisterMessageReceivers()
        {
        }

        public void SendCompositionMessages()
        {

            var data = new List<LazyDisplayItem<UserControl>>();

            #region samples data:

            var item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new ContextMenuSample()),
                "ContextMenuSample",
                "Context menu support of Silverlight 4.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new DataGridRowDetails()),
                "DataGridRowDetails",
                "DataGrid with Row Details.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new DataGridRowDetails()),
                "VisualStateManagerWithDataTriggerSample",
                "How Silverlight handles the DataTrigger with Visual State Manager.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new KennyYoungFluidMoveBehaviorSample()),
                "KennyYoungFluidMoveBehaviorSample",
                "Blend Interactions: Kenny Young, FluidMoveBehavior and ListBox.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new KennyYoungLayoutStatesSample()),
                "KennyYoungLayoutStatesSample",
                "Blend Interactions: Kenny Young, ListBoxItem and LayoutStates.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new CollectionViewSourceMasterDetailSample()),
                "CollectionViewSourceMasterDetailSample",
                "Master-detail relationship of the DataGrid and the DataForm with a CollectionViewSource.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new MasterDetailSample()),
                "MasterDetailSample",
                "Master-detail relationship of the DataGrid and the DataForm.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new NetflixSample()),
                "NetflixSample",
                "The Netflix OData/WCF Service.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new PiNumberSample()),
                "PiNumberSample",
                "The Silverlight-enabled WCF Service.");
            data.Add(item);

            item = UserControlUtiltity.GetLazyDisplayItem(
                new Func<UserControl>(() => new ValidationSample()),
                "ValidationSample",
                "The validation features of Silverlight.");
            data.Add(item);

            #endregion

            var message = new LightMessage<IEnumerable<LazyDisplayItem<UserControl>>>(data)
            {
                Source = LightMessageSource.CompositionMessagingCore,
                UniqueId = "UserControlsPage"
            };

            Messenger.Default.Send(message);
        }

        #endregion
    }
}
